 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStElectronicReceiptDetails;
import com.zdkj.subway.stm.service.SwStElectronicReceiptDetailsService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;


/**
 * 
 *
 * @author songtuo
 * @date 2020-07-13 13:34:08
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstelectronicreceiptdetails" )
@Api(value = "swstelectronicreceiptdetails", tags = "管理")
public class SwStElectronicReceiptDetailsController {

    private final  SwStElectronicReceiptDetailsService swStElectronicReceiptDetailsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStElectronicReceiptDetails 
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStElectronicReceiptDetailsPage(Page page, SwStElectronicReceiptDetails swStElectronicReceiptDetails) {
        return R.ok(swStElectronicReceiptDetailsService.page(page, Wrappers.query(swStElectronicReceiptDetails)));
    }


    /**
     * 通过id查询
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStElectronicReceiptDetailsService.getById(id));
    }

    /**
     * 新增
     * @param swStElectronicReceiptDetails 
     * @return R
     */
    @ApiOperation(value = "新增", notes = "新增")
    @SysLog("新增" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('generator_swstelectronicreceiptdetails_add')" )
    public R save(@RequestBody SwStElectronicReceiptDetails swStElectronicReceiptDetails) {
        return R.ok(swStElectronicReceiptDetailsService.save(swStElectronicReceiptDetails));
    }

    /**
     * 修改
     * @param swStElectronicReceiptDetails 
     * @return R
     */
    /*@ApiOperation(value = "修改", notes = "修改")
    @SysLog("修改" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('generator_swstelectronicreceiptdetails_edit')" )
    public R updateById(@RequestBody SwStElectronicReceiptDetails swStElectronicReceiptDetails) {
        return R.ok(swStElectronicReceiptDetailsService.updateById(swStElectronicReceiptDetails));
    }*/

    /**
     * 修改
     * @param ticketTransferAmount
     *
     * @return R
     */
    @ApiOperation(value = "修改", notes = "修改")
    @SysLog("修改" )
    @PutMapping
    //@PreAuthorize("@pms.hasPermission('swstelectronicreceiptdetails_edit')" )
    public R updateElectronic(@RequestBody String ids, String ticketTransferAmount) {
        return R.ok(swStElectronicReceiptDetailsService.updateElectronic(ids,ticketTransferAmount));
    }

    /**
     * 通过id删除
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除", notes = "通过id删除")
    @SysLog("通过id删除" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('generator_swstelectronicreceiptdetails_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStElectronicReceiptDetailsService.removeById(id));
    }

}
